package View.Model;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

public class ObjectConverter {
    DefaultTreeModel treeModel;

    public DefaultTreeModel ObjectToTreeModel(Project aoObject){
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(TipoObjeto.PROJECT.getDescription() + aoObject.getProjectNome(), true);
        DefaultMutableTreeNode aoNode = new DefaultMutableTreeNode(TipoObjeto.PROTOCOL.getDescription() + aoObject.getProtocol().getNomeProt());
        root.add(aoNode);
        aoNode = new DefaultMutableTreeNode(TipoObjeto.SERVER.getDescription() + aoObject.getServer().getNomeServer());
        root.add(aoNode);
        treeModel = new DefaultTreeModel(root);
        for (Thing aoThing : aoObject.getThing()) {
            DefaultMutableTreeNode aoCoisa = new DefaultMutableTreeNode(aoThing.getNome());
            root.add(aoCoisa);
        }
        return treeModel;
    }
}
